<template>
  <a-collapse activeKey="1" expand-icon-position="right">
    <a-collapse-panel key="1" header="查询条件">
      <a-form-model
        :labelCol="{ md: { span: 4 }, xs: { span: 24 }, sm: { span: 12 } }"
        :wrapperCol="{ md: { span: 18 }, xs: { span: 24 }, sm: { span: 12 } }"
        :model="params"
        ref="paramsForm"
      >
        <a-row>
          <a-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8" :xxl="8">
            <a-form-model-item label="名称">
              <a-input
                v-keyupEnter="{ callback: handleRefresh }"
                v-model.trim="params.name"
                placeholder="请输入名称"
              />
            </a-form-model-item>
          </a-col>

          <a-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8" :xxl="8">
            <a-form-model-item label="组织维度">
              <a-select
                style="width: 100%"
                v-model="params.orgDimId"
                placeholder="请选择组织维度"
              >
                <a-select-option
                  v-for="item in orgDims"
                  :key="item.id"
                  :value="item.id"
                  >{{ item.name }}</a-select-option
                >
              </a-select>
            </a-form-model-item>
          </a-col>

          <!--按钮-->
          <a-col :xs="24" :sm="24" :md="8" :lg="8" :xl="8" :xxl="8">
            <a-form-model-item>
              <a-button
                icon="search"
                type="primary"
                :loading="loading"
                @click="handleRefresh"
                >查询</a-button
              >
              <a-divider type="vertical" />
              <a-button icon="reload" @click="handleReset">重置</a-button>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </a-collapse-panel>
  </a-collapse>
</template>
<script>
import { queryOrgDimSelect } from "@/api/sys/identity/orgDim";
export default {
  props: {
    loading: {
      type: Boolean,
    },
  },
  data() {
    return {
      // 组织维度下拉列表
      orgDims: [],
      // 要查询的参数
      params: {
        // 名称
        name: "",
        // 唯一标示
        orgDimId: "",
      },
    };
  },
  mounted() {
    queryOrgDimSelect().then((res) => {
      this.orgDims = res.data;
    });
  },
  methods: {
    //#region 查询数据
    handleRefresh() {
      this.$emit("handleRefresh");
    },
    //#endregion

    //#region 重置
    handleReset() {
      this.params.name = "";
      this.params.orgDimId = "";
      this.$refs.paramsForm.resetFields();
    },
    //#endregion
  },
};
</script>
